7  One-Way ANOVA

Sample Problems

7.1 About

the one-way ANOVA problems use the RamdomData class which requires:

  • an integer value for the number of groups
  • the sample size per group - all groups will have the same sample size
  • a call to the anova() method with test = "one-way"

Each of the problems below sets factor levels using a random integer between 2 and 5. Per-group sample size is randomly set between 5 and 15. An example funciton call is included below

n_groups = random.randint(2,5)
sample_size = random.randint(5,15)
RandomData(groups = n_groups, n = sample_size).anova(test = "one-way")

7.2 Problem 1

Given the following between-subjects data, use a one-way ANOVA with \(\alpha = {0.01}\)

A B C D E
46 49 58 42 65
40 57 45 31 59
49 67 51 36 61
41 65 63 40 60
36 50 54 47 51
25 52 45 49 61
35 58 48 44 50
45 65 49 45 55
55 55 45 36 57
36 46 70 26 56
39 57 59 48 65
39 67 35 55 58
26 52 67 40 63


Summary statistics for these data:
\(G = {3241} \quad \Sigma{X^2} = {169383} \quad k = {5} \quad N = {65}\)

\(T_{A} = {512} \quad SS_{A} = {843.08}\)
\(T_{B} = {740} \quad SS_{B} = {616.92}\)
\(T_{C} = {689} \quad SS_{C} = {1208.0}\)
\(T_{D} = {539} \quad SS_{D} = {745.23}\)
\(T_{E} = {761} \quad SS_{E} = {269.23}\)

State the Hypotheses
\(H_0: \mu_A = \mu_B = \mu_C = \mu_D = \mu_E\)
\(H_1:\) At least one mean is different

The decision criteria:

\(F_{crit} = {3.65}, \alpha = {0.01}\)

Calculate the Degrees of Freedom
\[df_{total} = N - 1\]
\[df_{total} = {65} - 1\]
\[df_{total} = {64}\]

\[df_{between} = k - 1\]
\[df_{between} = {5} - 1\]
\[df_{between} = {4}\]

\[df_{within} = N - K\]
\[df_{within} = {65} - {5}\]
\[df_{within} = {60}\]

Calculate the Sum of Squares
\[SS_{total} = \Sigma X^2 - \frac{G^2}{N}\]
\[SS_{total} = {169383} - \frac{3241^2}{65}\]
\[SS_{total} = {169383} - \frac{10504081}{65}\]
\[SS_{total} = {169383} - {161601.25}\]
\[SS_{total} = {7781.75}\]

\[SS_{within} = \Sigma SS_{inside\_each\_condition}\]
\[SS_{within} = {843.08 + 616.92 + 1208.0 + 745.23 + 269.23}\]
\[SS_{within} = {3682.46}\]

\[SS_{between} = SS_{total} - SS_{within}\]
\[SS_{between} = {7781.75} - {3682.46}\]
\[SS_{between} = {4099.29}\]

note: the other way to calculate \(SS_{betwen}\) is:
\[SS_{between} = \Sigma{\frac{T^2}{n}} - \frac{G^2}{N}\]

Calculate the Mean Squares
\[MS_{between} = \frac{SS_{between}}{df_{between}}\]
\[MS_{between} = \frac{4099.29}{4}\]
\[MS_{between} = {1024.82}\]

\[MS_{within} = \frac{SS_{within}}{df_{within}}\]
\[MS_{within} = \frac{3682.46}{60}\]
\[MS_{within} = {61.37}\]

Calculate the F-Ratio
\[F_{obt} = \frac{MS_{between}}{MS_{within}}\]
\[F_{obt} = \frac{1024.82}{61.37}\]
\[F_{obt} = {16.7}\]

Calculate \(\eta^2\)
\[\eta^2 = \frac{SS{between}}{SS_{total}}\]
\[\eta^2 = \frac{4099.29}{7781.75}\]
\[\eta^2 = {0.53}\]

The results:

reject the null hypothesis, results are significant,

\(F({4}, {60}) = {16.7}, p < {0.01}, \eta^2 = {0.53}\)

7.3 Problem 2

Given the following between-subjects data, use a one-way ANOVA with \(\alpha = {0.05}\)

A B C D
58 85 50 32
75 84 50 67
75 62 64 67
69 72 57 73
69 78 47 66
60 61 38 66
42 45 57 43
64 84 71 75
71 68 36 67
70 85 51 53


Summary statistics for these data:
\(G = {2507} \quad \Sigma{X^2} = {164581} \quad k = {4} \quad N = {40}\)

\(T_{A} = {653} \quad SS_{A} = {896.1}\)
\(T_{B} = {724} \quad SS_{B} = {1626.4}\)
\(T_{C} = {521} \quad SS_{C} = {1040.9}\)
\(T_{D} = {609} \quad SS_{D} = {1726.9}\)

State the Hypotheses
\(H_0: \mu_A = \mu_B = \mu_C = \mu_D\)
\(H_1:\) At least one mean is different

The decision criteria:

\(F_{crit} = {2.87}, \alpha = {0.05}\)

Calculate the Degrees of Freedom
\[df_{total} = N - 1\]
\[df_{total} = {40} - 1\]
\[df_{total} = {39}\]

\[df_{between} = k - 1\]
\[df_{between} = {4} - 1\]
\[df_{between} = {3}\]

\[df_{within} = N - K\]
\[df_{within} = {40} - {4}\]
\[df_{within} = {36}\]

Calculate the Sum of Squares
\[SS_{total} = \Sigma X^2 - \frac{G^2}{N}\]
\[SS_{total} = {164581} - \frac{2507^2}{40}\]
\[SS_{total} = {164581} - \frac{6285049}{40}\]
\[SS_{total} = {164581} - {157126.22}\]
\[SS_{total} = {7454.78}\]

\[SS_{within} = \Sigma SS_{inside\_each\_condition}\]
\[SS_{within} = {896.1 + 1626.4 + 1040.9 + 1726.9}\]
\[SS_{within} = {5290.3}\]

\[SS_{between} = SS_{total} - SS_{within}\]
\[SS_{between} = {7454.78} - {5290.3}\]
\[SS_{between} = {2164.48}\]

note: the other way to calculate \(SS_{betwen}\) is:
\[SS_{between} = \Sigma{\frac{T^2}{n}} - \frac{G^2}{N}\]

Calculate the Mean Squares
\[MS_{between} = \frac{SS_{between}}{df_{between}}\]
\[MS_{between} = \frac{2164.48}{3}\]
\[MS_{between} = {721.49}\]

\[MS_{within} = \frac{SS_{within}}{df_{within}}\]
\[MS_{within} = \frac{5290.3}{36}\]
\[MS_{within} = {146.95}\]

Calculate the F-Ratio
\[F_{obt} = \frac{MS_{between}}{MS_{within}}\]
\[F_{obt} = \frac{721.49}{146.95}\]
\[F_{obt} = {4.91}\]

Calculate \(\eta^2\)
\[\eta^2 = \frac{SS{between}}{SS_{total}}\]
\[\eta^2 = \frac{2164.48}{7454.78}\]
\[\eta^2 = {0.29}\]

The results:

reject the null hypothesis, results are significant,

\(F({3}, {36}) = {4.91}, p < {0.05}, \eta^2 = {0.29}\)

7.4 Problem 3

Given the following between-subjects data, use a one-way ANOVA with \(\alpha = {0.01}\)

A B
29 45
50 45
48 40
38 46
39 57
35 44
38 50
55 33
17 46
55 44
46 25
42 34
41 40
39 64
35 29


Summary statistics for these data:
\(G = {1249} \quad \Sigma{X^2} = {54835} \quad k = {2} \quad N = {30}\)

\(T_{A} = {607} \quad SS_{A} = {1361.73}\)
\(T_{B} = {642} \quad SS_{B} = {1432.4}\)

State the Hypotheses
\(H_0: \mu_A = \mu_B\)
\(H_1:\) At least one mean is different

The decision criteria:

\(F_{crit} = {7.64}, \alpha = {0.01}\)

Calculate the Degrees of Freedom
\[df_{total} = N - 1\]
\[df_{total} = {30} - 1\]
\[df_{total} = {29}\]

\[df_{between} = k - 1\]
\[df_{between} = {2} - 1\]
\[df_{between} = {1}\]

\[df_{within} = N - K\]
\[df_{within} = {30} - {2}\]
\[df_{within} = {28}\]

Calculate the Sum of Squares
\[SS_{total} = \Sigma X^2 - \frac{G^2}{N}\]
\[SS_{total} = {54835} - \frac{1249^2}{30}\]
\[SS_{total} = {54835} - \frac{1560001}{30}\]
\[SS_{total} = {54835} - {52000.03}\]
\[SS_{total} = {2834.97}\]

\[SS_{within} = \Sigma SS_{inside\_each\_condition}\]
\[SS_{within} = {1361.73 + 1432.4}\]
\[SS_{within} = {2794.13}\]

\[SS_{between} = SS_{total} - SS_{within}\]
\[SS_{between} = {2834.97} - {2794.13}\]
\[SS_{between} = {40.84}\]

note: the other way to calculate \(SS_{betwen}\) is:
\[SS_{between} = \Sigma{\frac{T^2}{n}} - \frac{G^2}{N}\]

Calculate the Mean Squares
\[MS_{between} = \frac{SS_{between}}{df_{between}}\]
\[MS_{between} = \frac{40.84}{1}\]
\[MS_{between} = {40.84}\]

\[MS_{within} = \frac{SS_{within}}{df_{within}}\]
\[MS_{within} = \frac{2794.13}{28}\]
\[MS_{within} = {99.79}\]

Calculate the F-Ratio
\[F_{obt} = \frac{MS_{between}}{MS_{within}}\]
\[F_{obt} = \frac{40.84}{99.79}\]
\[F_{obt} = {0.41}\]

Calculate \(\eta^2\)
\[\eta^2 = \frac{SS{between}}{SS_{total}}\]
\[\eta^2 = \frac{40.84}{2834.97}\]
\[\eta^2 = {0.01}\]

The results:

fail to reject the null hypothesis, results not significant,

\(F({1}, {28}) = {0.41}, p > {0.01}, \eta^2 = {0.01}\)

7.5 Problem 4

Given the following between-subjects data, use a one-way ANOVA with \(\alpha = {0.01}\)

A B
55 77
50 55
39 72
48 66
46 61
56 69
36 70
45 59


Summary statistics for these data:
\(G = {904} \quad \Sigma{X^2} = {53280} \quad k = {2} \quad N = {16}\)

\(T_{A} = {375} \quad SS_{A} = {344.88}\)
\(T_{B} = {529} \quad SS_{B} = {376.88}\)

State the Hypotheses
\(H_0: \mu_A = \mu_B\)
\(H_1:\) At least one mean is different

The decision criteria:

\(F_{crit} = {8.86}, \alpha = {0.01}\)

Calculate the Degrees of Freedom
\[df_{total} = N - 1\]
\[df_{total} = {16} - 1\]
\[df_{total} = {15}\]

\[df_{between} = k - 1\]
\[df_{between} = {2} - 1\]
\[df_{between} = {1}\]

\[df_{within} = N - K\]
\[df_{within} = {16} - {2}\]
\[df_{within} = {14}\]

Calculate the Sum of Squares
\[SS_{total} = \Sigma X^2 - \frac{G^2}{N}\]
\[SS_{total} = {53280} - \frac{904^2}{16}\]
\[SS_{total} = {53280} - \frac{817216}{16}\]
\[SS_{total} = {53280} - {51076.0}\]
\[SS_{total} = {2204.0}\]

\[SS_{within} = \Sigma SS_{inside\_each\_condition}\]
\[SS_{within} = {344.88 + 376.88}\]
\[SS_{within} = {721.76}\]

\[SS_{between} = SS_{total} - SS_{within}\]
\[SS_{between} = {2204.0} - {721.76}\]
\[SS_{between} = {1482.24}\]

note: the other way to calculate \(SS_{betwen}\) is:
\[SS_{between} = \Sigma{\frac{T^2}{n}} - \frac{G^2}{N}\]

Calculate the Mean Squares
\[MS_{between} = \frac{SS_{between}}{df_{between}}\]
\[MS_{between} = \frac{1482.24}{1}\]
\[MS_{between} = {1482.24}\]

\[MS_{within} = \frac{SS_{within}}{df_{within}}\]
\[MS_{within} = \frac{721.76}{14}\]
\[MS_{within} = {51.55}\]

Calculate the F-Ratio
\[F_{obt} = \frac{MS_{between}}{MS_{within}}\]
\[F_{obt} = \frac{1482.24}{51.55}\]
\[F_{obt} = {28.75}\]

Calculate \(\eta^2\)
\[\eta^2 = \frac{SS{between}}{SS_{total}}\]
\[\eta^2 = \frac{1482.24}{2204.0}\]
\[\eta^2 = {0.67}\]

The results:

reject the null hypothesis, results are significant,

\(F({1}, {14}) = {28.75}, p < {0.01}, \eta^2 = {0.67}\)

7.6 Problem 5

Given the following between-subjects data, use a one-way ANOVA with \(\alpha = {0.05}\)

A B C D
66 65 71 68
65 65 73 79
70 59 55 70
74 55 72 79
68 62 73 64
66 70 69 70
75 63 66 71
68 60 71 73
75 54 75 72
77 60 59 77
79 59 69 70
69 60 67 60
69 54 72 69


Summary statistics for these data:
\(G = {3521} \quad \Sigma{X^2} = {240637} \quad k = {4} \quad N = {52}\)

\(T_{A} = {921} \quad SS_{A} = {253.69}\)
\(T_{B} = {786} \quad SS_{B} = {259.23}\)
\(T_{C} = {892} \quad SS_{C} = {401.08}\)
\(T_{D} = {922} \quad SS_{D} = {354.92}\)

State the Hypotheses
\(H_0: \mu_A = \mu_B = \mu_C = \mu_D\)
\(H_1:\) At least one mean is different

The decision criteria:

\(F_{crit} = {2.8}, \alpha = {0.05}\)

Calculate the Degrees of Freedom
\[df_{total} = N - 1\]
\[df_{total} = {52} - 1\]
\[df_{total} = {51}\]

\[df_{between} = k - 1\]
\[df_{between} = {4} - 1\]
\[df_{between} = {3}\]

\[df_{within} = N - K\]
\[df_{within} = {52} - {4}\]
\[df_{within} = {48}\]

Calculate the Sum of Squares
\[SS_{total} = \Sigma X^2 - \frac{G^2}{N}\]
\[SS_{total} = {240637} - \frac{3521^2}{52}\]
\[SS_{total} = {240637} - \frac{12397441}{52}\]
\[SS_{total} = {240637} - {238412.33}\]
\[SS_{total} = {2224.67}\]

\[SS_{within} = \Sigma SS_{inside\_each\_condition}\]
\[SS_{within} = {253.69 + 259.23 + 401.08 + 354.92}\]
\[SS_{within} = {1268.92}\]

\[SS_{between} = SS_{total} - SS_{within}\]
\[SS_{between} = {2224.67} - {1268.92}\]
\[SS_{between} = {955.75}\]

note: the other way to calculate \(SS_{betwen}\) is:
\[SS_{between} = \Sigma{\frac{T^2}{n}} - \frac{G^2}{N}\]

Calculate the Mean Squares
\[MS_{between} = \frac{SS_{between}}{df_{between}}\]
\[MS_{between} = \frac{955.75}{3}\]
\[MS_{between} = {318.58}\]

\[MS_{within} = \frac{SS_{within}}{df_{within}}\]
\[MS_{within} = \frac{1268.92}{48}\]
\[MS_{within} = {26.44}\]

Calculate the F-Ratio
\[F_{obt} = \frac{MS_{between}}{MS_{within}}\]
\[F_{obt} = \frac{318.58}{26.44}\]
\[F_{obt} = {12.05}\]

Calculate \(\eta^2\)
\[\eta^2 = \frac{SS{between}}{SS_{total}}\]
\[\eta^2 = \frac{955.75}{2224.67}\]
\[\eta^2 = {0.43}\]

The results:

reject the null hypothesis, results are significant,

\(F({3}, {48}) = {12.05}, p < {0.05}, \eta^2 = {0.43}\)